using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using WMVConvert.Metadata;

namespace WMVConvert.Tests
{

	[TestClass]
	public class SetMetadataFixture
	{
		[TestMethod]
		public void GetMovieNameFormat()
		{
			SetMetadata target = new SetMetadata();
			target.Force = false;
			string movieName = "Movie name";
			string year = "2005";
			FileInfo fi = new FileInfo(movieName+"("+year+").avi");
			IDictionary<string,object> metadata = new Dictionary<string,object>();
			target.SearchForMetadata(fi, ref metadata);
			Assert.AreEqual<string>(movieName, metadata["Title"].ToString());
			Assert.AreEqual<string>(year, metadata["WM/Year"].ToString());
			metadata.Clear();
		}

		[TestMethod]
		public void GetTVSeriesFormat()
		{
			SetMetadata target = new SetMetadata();
			target.Force = false;
			string tvShowName = "TVShow name";
			string episodeName = "Episode name";
			string episodeNumber = "08";
			string seasonNumber = "2";
			FileInfo fi = new FileInfo(tvShowName + " " + seasonNumber + "x" + episodeNumber + " - " + episodeName + ".wmv");
			IDictionary<string, object> metadata = new Dictionary<string, object>();
			target.SearchForMetadata(fi, ref metadata);
			Assert.AreEqual<string>(tvShowName, metadata["Title"].ToString());
			Assert.AreEqual<string>(episodeNumber + " " + episodeName, metadata["WM/SubTitle"].ToString());
			Assert.AreEqual<string>(episodeNumber, metadata["WM/TrackNumber"].ToString());
			metadata.Clear();
		}

		[TestMethod]
		public void GetTVSeriesNameWithPreviousValues()
		{
			SetMetadata target = new SetMetadata();
			target.Force = false;
			string tvShowName = "TVShow name";
			string previousTitle = "Previous Title";
			string episodeName = "Episode name";
			string episodeNumber = "08";
			string seasonNumber = "2";
			FileInfo fi = new FileInfo(tvShowName + " " + seasonNumber + "x" + episodeNumber + " - " + episodeName + ".wmv");
			IDictionary<string, object> metadata = new Dictionary<string, object>();
			metadata.Add("Title", previousTitle);
			target.SearchForMetadata(fi, ref metadata);
			Assert.AreEqual<string>(previousTitle, metadata["Title"].ToString());
			Assert.AreEqual<string>(episodeNumber + " " + episodeName, metadata["WM/SubTitle"].ToString());
			Assert.AreEqual<string>(episodeNumber, metadata["WM/TrackNumber"].ToString());
			metadata.Clear();
		}


	}
}
